import React, { useState, useEffect } from 'react'
import { View, Image, Swiper, SwiperItem, Text,Button } from '@tarojs/components'
import { AtList, AtListItem, AtButton, AtToast } from "taro-ui"

import useModel from 'flooks';
import store from '../../../stores/index'

import './index.less'
import "taro-ui/dist/style/components/list.scss";
import "taro-ui/dist/style/components/button.scss";
import Taro from '@tarojs/taro'


export default (props: any) => {
  const { ticket } = props.data
  const { detailDataChange } = useModel(store.detailData, ['detailData'])
  const toOlder = (i:any)=>{
    detailDataChange(props.data)
    Taro.navigateTo({
      url:`/pages/uBuy/index?ids=${i}`
    })
  }
  return (
    <View className='ticket'>
       <View className='title'>可选套餐</View>
      {
        ticket&&ticket.map((item: any, i: any) => (
          <View className='list'>
            <View className='listL'>
              {/* <View className='l1'>{item.title} </View> */}
              <View className='l2'>{item.content}</View>
              <View className='l3'>
                <Text className='l3_1'>¥{item.price}</Text>
                <Text className='l3_2'>¥{item.priceOld}</Text>
                <View className='p3'>剩余：{item.numTotal-item.num}</View> 
              </View>
            </View>
            <Button disabled={item.numTotal-item.num<=0}  className={item.numTotal-item.num<=0?'listR listRDis':'listR'}  onClick={()=>{toOlder(i)}}>{item.numTotal-item.num<=0?'已售罄':'立即抢购'}</Button>
          </View>
        ))
      }
    </View>
  )
}
